package main
import (
	"fmt"
)

// 10. switch 语句
func main(){

	finger := 41
	switch finger {
		case 1:
			fmt.Println("finger= ", finger)
		case 2:
			fmt.Println("finger= ", finger)
		case 3:
			fmt.Println("finger= ", finger)
		case 4:
			fmt.Println("finger= ", finger)
		case 5:
			fmt.Println("finger= ", finger)
		default:
			fmt.Println("找不到finger=", finger)
	}

	letter := "a"
	switch letter {
		case "a", "b", "c", "d":
			fmt.Println("letter=",letter)
		default:
			fmt.Println("找不到 letter=", letter)

	}

	// fallthrough  会执行后面的case 不用判断条件
	switch num := number(); {
		case num < 50 :
			fmt.Printf("\n%d is lesser than 50", num)
			fallthrough
		case num < 100:
			fmt.Printf("\n%d is lesser than 100", num)
			fallthrough
		case num < 200:
			fmt.Printf("\n%d is lesser than 200", num)
			fallthrough
		case num < 20:
			fmt.Printf("\n%d is lesser than 20", num)
			fallthrough
		default:
			fmt.Printf("\n%d is lesser than default", num)
	}
}

func number() int {
	num := 15 * 5
	return num
}
